`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company: 
// Engineer: Rohit Kulkarni, Vedang Vaidya
// 
// Create Date:    09:09:05 04/04/2014 
// Design Name: 
// Module Name:    Code_Converter 
// Project Name: 
// Target Devices: 
// Tool versions: 
// Description: Code converter module for the Rojobot
//
// Dependencies: 
//
// Revision: 
// Revision 0.01 - File Created
// Additional Comments: 
//
//////////////////////////////////////////////////////////////////////////////////
module Code_Converter(
	input 		[4:0]	pbtn_db, 		// debounced pushbuttons as inputs
	output reg	[2:0] motion_mode   			// 3 bit motion mode as output for the seven possible motion modes
	 );

// Rojobot's Motion Modes
parameter STOP 			= 3'b000;
parameter TURN_RIGHT_1X = 3'b001;
parameter TURN_RIGHT_2X = 3'b010;
parameter TURN_LEFT_1X 	= 3'b011;
parameter TURN_LEFT_2X 	= 3'b100;
parameter FORWARD 		= 3'b101;
parameter REVERSE 		= 3'b110;

/*
		.left_fwd(db_btns[4]),
      .left_rev(db_btns[3]), 
      .right_fwd(db_btns[2]),
      .right_rev(db_btns[1]),

*/
	always @(*)
	begin
		case (pbtn_db)
			5'b00000: motion_mode = STOP;
			5'b11000: motion_mode = STOP;
			5'b00110: motion_mode = STOP;
			5'b10000: motion_mode = TURN_RIGHT_1X;
			5'b00010: motion_mode = TURN_RIGHT_1X;
			5'b10010: motion_mode = TURN_RIGHT_2X;
			5'b00100: motion_mode = TURN_LEFT_1X;
			5'b01000: motion_mode = TURN_LEFT_1X;
			5'b01100: motion_mode = TURN_LEFT_2X;
			5'b10100: motion_mode = FORWARD;
			5'b01010: motion_mode = REVERSE;
			default:  motion_mode = STOP;				
		endcase
	end
endmodule
